/**
 * 数组动态内存分配相关的操作
*/
#ifndef ARRAY
#define ARRAY
int **init2D(int n) {
    int** a = (int**) calloc(sizeof(int*), n);
    for (int i=0; i<n; i++) {
        a[i] = (int*) calloc(sizeof(int), n);
    }
    return a;
}

void free2D(int **a, int n) {
    for (int i=0; i<n; i++) {
        free(a[i]);
    }
    free(a);
}

void print2D(int **m, int n, int defaultWeight) {
    for (int i=-1; i<n; i++) {
        printf("[%3d]", i);
    }
    printf("\n");
    for (int i=0; i<n; i++) {
        printf("[%3d]", i);
        for (int j=0; j<n; j++) {
            if (m[i][j] == defaultWeight) {
                printf("    -");
            } else {
                printf("%5d", m[i][j]);
            }
        }
        printf("\n");
    }
}

void print1D(char* name, int array[], int n) {
    printf("%s: ", name);
    for (int i=0; i < n; i++) {
        printf("%d ", array[i]);
    }
    printf("\n");
}

#endif